#!/usr/bin/perl
use strict;

chdir "/opt/down/done/upd";

if(0)
{ # sync from source
our $Base="http://cdit/Z/Distribs/AntiVirus/McAfee/cmd/new/";

use LWP::UserAgent;
use LWP::ConnCache;

my $ua= LWP::UserAgent->new();
$ua->conn_cache(LWP::ConnCache->new());
$ua->agent("Dat Fetcher by Gimly/1.0");

$ua->mirror($Base.$_,"DAT/".$_)	foreach qw/version.txt avvclean.dat avvnames.dat avvscan.dat/;
}

# read version
{open IN,'DAT/version.txt';undef local $/;$_=<IN>;close IN;}
die "wrong version format: ".$_ unless /AVDatVersion\s+REG_DWORD\s+0x(\w+)/;
my $ver=hex $1;
#print "Found version $ver\n";

my $res="inc/avvdat-$ver.zip";


if(-e $res)
{
print("Already $res - ignoring\n") if -t STDOUT;
exit
}

symlink "avvdat.zip",$res;

exec "./ZipFormat.pl", $ver;
